<?php
namespace app\admin\validate;

use think\Validate;
use Session;
use app\common\model\User;

class AddUser extends Validate
{
    protected $rule =   [
        'username'  => 'require|alphaDash',
        'password'   => 'length:4,25',

    ];

    protected $message  =   [
        'username.require' => '用户名必须填写',
        'username.alphaDash' => '用户名格式错误',
        'password'     => '密码长度不符合，4-25个字符',

    ];


    public function checkDo($param){
        $model = new User();
        $exists = $model->where('username',$param['username'])->find();

        if($exists){
            exception('用户已经存在！');
        }



        return $this->check($param);
    }



}